/*
 * Copyright(C) Chris2018998
 * Contact:Chris2018998@tom.com
 *
 * Licensed under GNU Lesser General Public License v2.1
 */
package org.stone.beecp.mock;

import java.sql.*;

/**
 * @author Chris Liao
 * @version 1.0
 */
public class MockStatement extends MockBase implements Statement {
    MockResultSet resultSet;
    MockConnection connection;
    private int queryTimeout;
    private int maxFieldSize;
    private int maxRows;
    private int fetchSize;

    MockStatement(MockConnection connection) {
        this.connection = connection;
    }

    public Connection getConnection() {
        return connection;
    }

    public void close() throws SQLException {
        super.close();
        resultSet = null;
    }

    public ResultSet executeQuery(String sql) {
        resultSet = new MockResultSet(this);
        return resultSet;
    }

    public int executeUpdate(String sql) {
        return 1;
    }

    public int getMaxFieldSize() {
        return maxFieldSize;
    }

    public void setMaxFieldSize(int max) {
        maxFieldSize = max;
    }

    public int getMaxRows() {
        return maxRows;
    }

    public void setMaxRows(int max) {
        maxRows = max;
    }

    public void setEscapeProcessing(boolean enable) {
        //do nothing
    }

    public int getQueryTimeout() {
        return queryTimeout;
    }

    public void setQueryTimeout(int seconds) {
        queryTimeout = seconds;
    }

    public void cancel() {
        //do nothing
    }

    public SQLWarning getWarnings() {
        return null;
    }

    public void clearWarnings() {
        //do nothing
    }

    public void setCursorName(String name) {
        //do nothing
    }

    public boolean execute(String sql) {
        return true;
    }

    public ResultSet getResultSet() {
        return resultSet;
    }

    public int getUpdateCount() {
        return 1;
    }

    public boolean getMoreResults() {
        return true;
    }

    public int getFetchDirection() {
        return 1;
    }

    public void setFetchDirection(int direction) {
        //do nothing
    }

    public int getFetchSize() {
        return fetchSize;
    }

    public void setFetchSize(int rows) {
        fetchSize = rows;
    }

    public int getResultSetConcurrency() {
        return 1;
    }

    public int getResultSetType() {
        return 1;
    }

    public void addBatch(String sql) {
        //do nothing
    }

    public void clearBatch() {
        //do nothing
    }

    public int[] executeBatch() {
        return null;
    }

    public boolean getMoreResults(int current) {
        return false;
    }

    public ResultSet getGeneratedKeys() {
        return new MockResultSet(this);
    }

    public int executeUpdate(String sql, int autoGeneratedKeys) {
        return 1;
    }

    public int executeUpdate(String sql, int[] columnIndexes) {
        return 1;
    }

    public int executeUpdate(String sql, String[] columnNames) {
        return 1;
    }

    public boolean execute(String sql, int autoGeneratedKeys) {
        return true;
    }

    public boolean execute(String sql, int[] columnIndexes) {
        return true;
    }

    public boolean execute(String sql, String[] columnNames) {
        return true;
    }

    public int getResultSetHoldability() {
        return 1;
    }

    public boolean isPoolable() {
        return false;
    }

    public void setPoolable(boolean poolable) {
        //do nothing
    }

    public void closeOnCompletion() {
        //do nothing
    }

    public boolean isCloseOnCompletion() {
        return false;
    }
}
